<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/4 0004
 * Time: 下午 8:34
 */

namespace App\Http\Middleware;

use App\Model\Permissions;
use App\Model\PermissionsDetail;
use Closure;
class CheckLogin
{
    public function handle($request, Closure $next)
    {
        if (empty(session('admin_user'))){
             return redirect('/admin/login/login')->withErrors('你还未登录请先登录');
   }
// else{
            $response = $next($request);
//            //当前用户
//            $user = session('admin_user');
//            //请求地址
//            $requestUrl = $request->getRequestUri();
//            //当前用户所有权限
//            $permissionDetail = PermissionsDetail::where('user_id',$user['id'])->get()->toArray();
//            foreach ($permissionDetail as $value){
////                return view('Admin.public.menu',['data'=>$value]);
//            }
//
//
//            // 执行动作
            return $response;
//        }

    }

}